class MyArray<E>{
    public Object[] array = new Object[10];

    public void setVal(int pos,E val){
        this.array[pos]=val;
    }

    public E getVal(int pos){
        return (E)array[pos];
    }
}
public class Test {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray();
        myArray.setVal(0,10);
        myArray.setVal(1,20);
        //myArray.setVal(2,"hello"); err,因为泛型会自动类型检测
        int ret = myArray.getVal(1);//这边的动作属于是自动装箱
        System.out.println(ret);
    }
}
